package com.github.pig.admin.service.tsjy.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pig.admin.mapper.tsjy.SuggestRecordMapper;
import com.github.pig.admin.model.tsjy.SuggestRecord;
import com.github.pig.admin.model.tsjy.SuggestRecordWhere;
import com.github.pig.admin.model.zhgl.propertyassess.PropertyAssessCount;
import com.github.pig.admin.service.tsjy.ISuggestRecordService;
import com.github.pig.admin.util.AjaxJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 投诉建议记录表 服务实现类
 * </p>
 *
 * @author lxm
 * @since 2018-06-22
 */
@Service
public class SuggestRecordServiceImpl extends ServiceImpl<SuggestRecordMapper, SuggestRecord> implements ISuggestRecordService {

    @Autowired
    private SuggestRecordMapper suggestRecordMapper;
    @Override
    public SuggestRecord getSuggestRecordById(String suggestRecordId) {
        return suggestRecordMapper.getSuggestRecordById(suggestRecordId);
    }
    @Override
    public AjaxJson getSumSuggests(SuggestRecordWhere suggestRecordWhere){

            // 定义投诉建议总数sumSuggest
            Integer sumSuggest = 0 ;
            AjaxJson json = new AjaxJson();
            try {
                List<SuggestRecord> list = suggestRecordMapper.getSumSuggests(suggestRecordWhere);
                sumSuggest = list.size();
            json.setObj(sumSuggest);
            json.setSuccess(true);
            json.setMsg("获取投诉建议总数成功");
            }catch (Exception e){
            json.setMsg("获取投诉建议总数失败");
            json.setSuccess(false);
            }

            return json;
    }
}
